package top.mayyd.producteurekaservice.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.mayyd.producteurekaservice.domain.Product;
import top.mayyd.producteurekaservice.mapper.ProductMapper;

import java.util.List;
import java.util.Random;

@Service
public class ProductService {
    @Autowired
    private ProductMapper productMapper;

    public List<Product> getAll() {
        List<Product> products = productMapper.selectAll();

        return products;
    }

    public Product getById(Long id) {
        Product p = productMapper.selectByPrimaryKey(id);
        //随机休眠0-2s
        /*try {
            Thread.sleep(new Random().nextInt(1000) + 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

        return p;
    }
}
